/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 50;
    vc.extends({
        data: {
            storeOrderUpManageInfo: {
                storeOrderUps: [],
                total: 0,
                records: 1,
                conditions: {
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that._lisStoreOrderUps(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('storeOrderUpManage', 'listStoreOrderUp', function (_param) {
                $that._lisStoreOrderUps(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._lisStoreOrderUps(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _lisStoreOrderUps: function (_page, _rows) {
                $that.storeOrderUpManageInfo.conditions.page = _page;
                $that.storeOrderUpManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.storeOrderUpManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/storeOrderUp/queryStoreOrderUp',
                    param,
                    function (json, res) {
                        var _storeOrderUpManageInfo = JSON.parse(json);
                        $that.storeOrderUpManageInfo.total = _storeOrderUpManageInfo.total;
                        $that.storeOrderUpManageInfo.records = _storeOrderUpManageInfo.records;
                        $that.storeOrderUpManageInfo.storeOrderUps = _storeOrderUpManageInfo.data;
                        console.log($that.storeOrderUpManageInfo.storeOrderUps);
                        vc.emit('pagination', 'init', {
                            total: $that.storeOrderUpManageInfo.records,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _StoreOrderUp: function (_storeOrderUp) {
                vc.emit('goodCashier', 'storeOrderUpManage', {
                    _storeOrderUp
                });
            },
            _openDeleteStoreOrderUpModel: function (_storeOrderUp) {
                vc.emit('deleteStoreOrderUp', 'openDeleteStoreOrderUpModal', _storeOrderUp);
            },
            _back: function () {
                vc.emit('goodCashier', 'storeOrderUpManage', {});
            },
            _moreCondition: function () {
                if ($that.storeOrderUpManageInfo.moreCondition) {
                    $that.storeOrderUpManageInfo.moreCondition = false;
                } else {
                    $that.storeOrderUpManageInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
